import { upload } from "../util/multer.js"
import express from 'express';
import homeRouter from './commonRouter/homeRouter.js';
import registerRouter from './commonRouter/registerRouter.js';
import loginRouter from './commonRouter/loginRouter.js';
import userRouter from './userRouter/userRouter.js'
import petRouter from './petRouter/petRouter.js';
import baseRouter from './commonRouter/baseRouter.js';
import messageRouter from './messageRouter/messageRouter.js';
import diaryRouter from './diaryRouter/diaryRouter.js';
import breedRouter from "./breedRouter/breedRouter.js";
import starRouter from "./starRouter/starRouter.js";
import adopterRouter from "./adopterRouter/adopterRouter.js";
import menuRouter from "./menuRouter/menuRouter.js";

const router = express.Router();


// 单独文件上传
router.use('/upload', upload.single('file'), (req, res) => {
    const imgURL = `http://localhost:8088/static/uploads/${req.file.filename}`;
    res.json({ imgURL });
})

router.delete('/upload/preview', (req, res) => {

})
router.use('/base', baseRouter)
router.use('/home', homeRouter)
router.use('/user', userRouter)
router.use('/pet', petRouter)
router.use('/register', registerRouter)
router.use('/login', loginRouter)
router.use('/message', messageRouter)
router.use('/diary', diaryRouter)
router.use('/breed', breedRouter)
router.use('/star', starRouter)
router.use('/adopter', adopterRouter)
router.use('/menu',menuRouter)
export default router;